package com.project.hqshorttaxi.service.impl;

import com.project.hqshorttaxi.entity.Setting;
import com.project.hqshorttaxi.mapper.SettingMapper;
import com.project.hqshorttaxi.service.SettingService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

@Service
public class SettingServiceImpl implements SettingService {

    @Resource
    private SettingMapper settingMapper;

    @Override
    public Setting getById(Integer id) {
        return settingMapper.selectByPrimaryKey(id);
    }

    @Transactional(rollbackFor = Exception.class)
    @Override
    public void insert(Setting entity) throws Exception {
        settingMapper.insertSelective(entity);
    }

    @Transactional(rollbackFor = Exception.class)
    @Override
    public void update(Setting entity) throws Exception {
        settingMapper.updateByPrimaryKeySelective(entity);
    }

    @Transactional(rollbackFor = Exception.class)
    @Override
    public void delete(Integer id) throws Exception {
        settingMapper.deleteByPrimaryKey(id);
    }

    @Override
    public List<Setting> list() {
        List<Setting> list = settingMapper.selectAll();
        return list;
    }
}
